Skip to content

[codex] Structure desktop Clerk bridge failures#3308

Merged
juliusmarminge merged 1 commit into
mainfrom
codex/desktop-clerk-bridge-errors
Jun 20, 2026
Merged

[codex] Structure desktop Clerk bridge failures#3308
juliusmarminge merged 1 commit into
mainfrom
codex/desktop-clerk-bridge-errors

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • add Schema-backed errors for Clerk bridge initialization and cleanup with state-directory and environment context
  • preserve the exact SDK cause; initialization stays typed while cleanup becomes a structured finalizer defect
  • construct errors directly at the boundary and export the existing service make value
  • cover both failure paths with focused layer lifecycle tests

Verification

  • vp test apps/desktop/src/app/DesktopClerk.test.ts
  • vp check (passes with 20 pre-existing warnings)
  • vp run typecheck

Open PR overlap audit

The exact source and test files are also touched by unrelated local-auth startup PR #3252. This PR is a focused error-boundary change and does not overlap the active Effect/error audit series.


Note

Medium Risk
Touches desktop Clerk startup/teardown on the auth path; behavior on success is unchanged, but init failures are now typed and cleanup failures become defects via orDie.

Overview
Wraps desktop Clerk bridge acquire/release in Effect.try and maps SDK throws to two new Schema tagged errors—DesktopClerkBridgeInitializationError and DesktopClerkBridgeCleanupError—each carrying stateDir, isDevelopment, and the original cause.

Initialization failures surface as typed layer errors; cleanup failures are still structured then passed through Effect.orDie on the release finalizer. make is exported for tests.

Tests add a shared layer helper, per-test mock resets, and layer lifecycle cases that assert message text and cause preservation for both failure paths.

Reviewed by Cursor Bugbot for commit 96a7ff0. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add structured error types for desktop Clerk bridge initialization and cleanup failures

  • Adds DesktopClerkBridgeInitializationError and DesktopClerkBridgeCleanupError tagged error classes in DesktopClerk.ts, each carrying stateDir, isDevelopment, and cause fields.
  • Reworks the DesktopClerk.make layer factory to wrap bridge creation in Effect.try, surfacing init failures as typed errors, and wraps bridge.cleanup similarly, converting cleanup failures to defects via Effect.orDie.
  • Adds tests in DesktopClerk.test.ts covering both failure paths, with a beforeEach mock reset to prevent cross-test interference.
  • Behavioral Change: bridge initialization failures now produce a typed DesktopClerkBridgeInitializationError instead of an unstructured exception; cleanup failures now terminate the process as a defect rather than being silently swallowed.

Macroscope summarized 96a7ff0.

Co-authored-by: codex <codex@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1d5dbf0b-7b58-4f23-875f-16188b7440fe

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/desktop-clerk-bridge-errors

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jun 20, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

This PR adds structured error classes for Clerk bridge initialization and cleanup failures, improving error diagnostics without changing core behavior. The changes are self-contained with comprehensive test coverage.

You can customize Macroscope's approvability policy. Learn more.

@juliusmarminge juliusmarminge merged commit 48f88d5 into main Jun 20, 2026
16 checks passed
@juliusmarminge juliusmarminge deleted the codex/desktop-clerk-bridge-errors branch June 20, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant